/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.aseclipse.core.runtime.registry.classes {

import org.aseclipse.core.runtime.registry.IExtension;
import org.aseclipse.core.runtime.registry.IExtensionDelta;

/*
 * Basic implementation for now...
 */
public class RegistryDelta {
	private var extensionDeltas:Array = new Array();
	private var hostName:String;

	public function RegistryDelta(hostName:String) {
		this.hostName = hostName;
	}
	public function getExtensionDeltasCount():int {
		return extensionDeltas.length;
	}
	public function getAllExtensionDeltas():Array {
		return extensionDeltas;
	}
	public function getExtensionDeltas(extensionPoint:String):Array {
		var selectedExtDeltas:Array = new Array();
		for each(var extensionDelta:IExtensionDelta in extensionDeltas) {
			if (extensionDelta.extension.getExtensionPointIdentifier() == extensionPoint)
				selectedExtDeltas.push(extensionDelta);
		}
		return selectedExtDeltas;
	}
	/**
	 * @param extensionPointId
	 * @param extensionId must not be null
	 */
	public function getExtensionDelta(extensionPointId:String, extensionId:String):IExtensionDelta {
		for each(var extensionDelta:IExtensionDelta in extensionDeltas) {
			var extension:IExtension = extensionDelta.extension;
			if (extension.getExtensionPointIdentifier() == extensionPointId && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier() == extensionId)
				return extensionDelta;
		}
		return null;
	}
	public function addExtensionDelta(extensionDelta:IExtensionDelta):void {
		this.extensionDeltas.push(extensionDelta);
	}
	public function toString():String {
		return "\n\tHost " + hostName + ": " + extensionDeltas; //$NON-NLS-1$//$NON-NLS-2$
	}

}
}